<template>
	<view class="house">
		<u-search v-model="value" @search="search" @custom="search"></u-search>
		<u-tabs :list="type" :scrollable="false" @click="clicktype"></u-tabs>
		<view class="h1" v-for="item in list" @click="tonext(item.id)">
			<view class="h3">
				<image :src="'http://124.93.196.45:10001'+item.pic"></image>
			</view>
			<view class="h2">
				<text>地址：{{item.address}}</text>
				<text>面积：{{item.areaSize}}</text>
				<text>价格：{{item.price}}</text>
				<text>简介：{{item.description}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type:[
					{
						name:'二手'
					},
					{
						name:'租房'
					},
					{
						name:'楼盘'
					},
					{
						name:'中介'
					}
				],
				list:[],
				alllist:[],
				value:''
			}
		},
		onLoad() {
			this.getlist()
		},
		methods: {
			getlist(){
				this.api.get('/prod-api/api/house/housing/list').then(res=>{
					this.list=res.data.rows
					this.alllist=res.data.rows
				})
			},
			clicktype(e){
				this.api.get('/prod-api/api/house/housing/list?houseType='+e.name).then(res=>{
					this.list=res.data.rows
				})
			},
			search(){
				if(this.value===''){
					this.list=this.alllist
				}else{
					this.list=[]
					this.api.get('/prod-api/api/house/housing/list?sourceName='+this.value).then(res=>{
						this.list=res.data.rows
					})
				}
			},
			tonext(id){
				uni.navigateTo({
					url:'/pages/other/house/houseDetail/houseDetail?id='+id
				})
			}
		}
	}
</script>

<style lang="scss">
.h1{
	display: flex;
	border-bottom: 1px solid #ccc;
	.h3{
		width: 50%;
		// border: 2px solid red;
		margin-top: 20px;
		image{
			width: 150px;
			height: 150px;
			margin-top: 20px;
		}
	}
	.h2{
		margin-left: 15px;
		margin-top: 20px;
		line-height: 27px;
		display: flex;
		flex-direction: column;
	}
}
</style>
